home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / utility / crypchal.zip / CANT.C next >
C/C++ Source or Header  |  1994-04-17  |  491b  |  24 lines

  1. /*
  2. **  CANT.C - An fopen() replacement with error trapping
  3. **
  4. **  public domain by Bob Stout
  5. **
  6. **  Call just as you would fopen(), but make sure your exit functions are
  7. **  registered with atexit().
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12.  
  13. FILE *cant(char *fname, char *fmode)
  14. {
  15.       FILE *fp;
  16.  
  17.       if (NULL == (fp = fopen(fname, fmode)))
  18.       {
  19.             fprintf(stderr, "Can't open %s\n", fname);
  20.             exit(EXIT_FAILURE);
  21.       }
  22.       return fp;
  23. }
  24.